Skip to content

Conversation

@sabiwara
Copy link
Contributor

@sabiwara sabiwara commented Jan 8, 2025

Close #14153

receiver

[head | tail] ->
case Macro.expand_once(head, env) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think then we need to replace this by expand instead of expand_once. Otherwise if you have a macro this macro:

defmacro current_module do
  quote do
    __MODULE__
  end
end

and this typespec:

current_module().Foo.Bar

It will no longer work, as the first expansion will return __MODULE__.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think then we need to replace this by expand instead of expand_once.

Done in 3abb13b

It will no longer work,

Just FYI, I checked and this was an infinite loop as well so technically it did never worked (we were returning the pre-expansion alias as is and kept looping). I agree we should fix it of course.

Copy link
Member

@josevalim josevalim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please backport

@sabiwara sabiwara merged commit 8cd2915 into elixir-lang:main Jan 9, 2025
9 checks passed
@sabiwara sabiwara deleted the inf-loop-typespec branch January 9, 2025 09:26
@sabiwara
Copy link
Contributor Author

sabiwara commented Jan 9, 2025

Backported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Compiler goes into an infinite loop with invalid @type

2 participants